<template>
  <div class="feature">
    <div class="block flex-center">
      <i class="iconfont" :class="featureDate.titleIcon"></i>
      <div class="title">{{ featureDate.title }}</div>
    </div>

    <div class="content">
      <div v-for="(item, i) in featureDate.children" :key="i" @click="handleClick(item, i, featureDate)">
        <i class="iconfont" :class="item.icon || ''" />
        <div class="card">{{ item.label }}</div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { toRefs } from "vue";

export interface Props {
  featureDate?: FeatureDateType<any>;
}

const props = withDefaults(defineProps<Props>(), {
  featureDate: () => ({} as any)
});

const emit = defineEmits(["itemClick"]);

const handleClick = (item: FeatureMenuType, index: number, featureDate: FeatureDateType<FeatureMenuType>) => {
  emit("itemClick", item, index, featureDate);
};

const { featureDate } = toRefs(props);
</script>

<style lang="scss" scoped>
@import "@/styles/var.scss";
.feature {
  box-shadow: $shadow;
  border-radius: 6px;
  position: relative;
  .block {
    padding: 10px 8px;
    background: $primary;
    position: absolute;
    top: 0;
    left: 26px;
    transform: translateY(-50%);
    border-radius: 6px;
    transition: all 0.3s;
    .iconfont {
      font-size: 20px;
      color: $white;
    }
    .title {
      padding: 0 10px;
      color: $white;
      font-size: 16px;
      font-weight: bold;
    }
  }
  .content {
    padding: 30px 16px 10px;
    display: flex;
    flex-wrap: wrap;
    .card {
      padding: 10px;
      border-radius: 6px;
      border: 1px solid $primary;
      margin: 10px;
      transition: all 0.4s;
      cursor: pointer;
      &:hover {
        transform: translateY(-10%);
      }
    }
  }
}
</style>
